<template>
<ContentWrap>
    <template #header>
        <el-space wrap>
            <el-button icon="download" @click="export2Excel()" title="导出当前结果" />
            <mdp-table-configs :column-configs="columnConfigs" v-model="checkedColumns"/>
            <span v-if="currOpType=='mng'">
                <el-button plain :disabled="disBtn('addBtn') || !checkBtnQx('addBtn',menuDefId) " type="primary" @click="openForm({parentOpType:currOpType,subOpType:'add',formData:addForm,title:'新增'})" icon="plus"/>
                <el-button plain :disabled="disBtn('delBtn') || !checkBtnQx('delBtn',menuDefId) || this.sels.length===0 || load.del==true" type="danger" v-loading="load.del" @click="batchDel" icon="delete"/>
            </span>
            <span v-else-if="currOpType=='select' &&  this.multiple==true">
                <el-button :disabled="disBtn('selectBtn') || this.sels.length===0" type="primary" @click="selectListConfirm" icon="check"/>
            </span>
        </el-space>
    </template>
    <el-space wrap>
        <mdp-select item-code="bizFlowState" v-model="filters.bizFlowState" />

        <el-input v-model="filters.joinUserid"  placeholder="申请人编号" clearable title="支持>、<、 >=、<=、!=、*字符*、$IS NULL、$IN 1,2,3、$between 1,5等操作符"/>
        <el-input v-model="filters.joinUsername"  placeholder="申请人姓名" clearable title="支持>、<、 >=、<=、!=、*字符*、$IS NULL、$IN 1,2,3、$between 1,5等操作符"/>
        <el-button v-loading="load.list" :disabled="load.list==true" @click="searchTableDatas()" icon="search" type="primary">查询</el-button>
    </el-space>
</ContentWrap>
<!--列表 UserJoinRequire 企业入驻审核流程-->
<el-table ref="UserJoinRequireTable'" v-adaptive :data="tableDatas" @sort-change="sortChange" highlight-current-row v-loading="load.list" border @selection-change="selsChange" @row-click="rowClick" style="width: 100%;">
    <el-table-column  type="selection" width="55" show-overflow-tooltip fixed="left" v-if="currOpType=='mng' || this.multiple==true"/>
    <el-table-column sortable type="index" width="55" show-overflow-tooltip  fixed="left"/>
    
    <el-table-column prop="joinUserid"  label="用户编号" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('joinUserid')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.joinUserid" :maxlength="50" @change="editSomeFields(scope.row,'joinUserid',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    <el-table-column prop="joinUsername"  label="用户名称" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('joinUsername')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.joinUsername" :maxlength="255" @change="editSomeFields(scope.row,'joinUsername',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column> 
    <el-table-column prop="createDate"  label="申请时间" min-width="120" show-overflow-tooltip col-type="Date" v-if="showCol('createDate')"/>

    <el-table-column prop="joinBranchId"  label="目标机构" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('joinBranchId')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.joinBranchId" :maxlength="50" @change="editSomeFields(scope.row,'joinBranchId',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    
    <el-table-column prop="joinReason"  label="加入理由" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('joinReason')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.joinReason" :maxlength="255" @change="editSomeFields(scope.row,'joinReason',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    <el-table-column prop="bizFlowState"  label="审核状态" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('bizFlowState')">
        <template #default="scope">
                <mdp-select item-code="bizFlowState" show-style="tag" v-model="scope.row.bizFlowState" :maxlength="1" @change="editSomeFields(scope.row,'bizFlowState',$event)" :disabled="disField"/>
        </template>
    </el-table-column>
    <el-table-column prop="joinUserPhoneno"  label="联系电话" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('joinUserPhoneno')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.joinUserPhoneno" :maxlength="20" @change="editSomeFields(scope.row,'joinUserPhoneno',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    <el-table-column prop="agreeDate"  label="同意时间" min-width="120" show-overflow-tooltip col-type="Date" v-if="showCol('agreeDate')">
        <template #default="scope">
                <mdp-date type="date" placeholder="选择日期" show-style="tag" v-model="scope.row.agreeDate" @change="editSomeFields(scope.row,'agreeDate',$event)"  value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    <el-table-column prop="joinStatus"  label="加入状态" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('joinStatus')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.joinStatus" :maxlength="1" @change="editSomeFields(scope.row,'joinStatus',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    
    <el-table-column prop="joinDeptid"  label="要加入的部门号" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('joinDeptid')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.joinDeptid" :maxlength="50" @change="editSomeFields(scope.row,'joinDeptid',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    <el-table-column prop="bizProcInstId"  label="当前流程实例编号" min-width="120" show-overflow-tooltip col-type="String" v-if="showCol('bizProcInstId')">
        <template #default="scope">
                <mdp-input show-style="tag" v-model="scope.row.bizProcInstId" :maxlength="50" @change="editSomeFields(scope.row,'bizProcInstId',$event)" :disabled="!someOpen||disField"/>
        </template>
    </el-table-column>
    <el-table-column label="操作" :width="currOpType=='mng'?180:180" fixed="right">
        <template #default="scope" v-if="currOpType=='mng'"  >
            <el-button :disabled="disBtn('editBtn') || !checkBtnQx('editBtn',menuDefId) " type="primary" @click="openForm({parentOpType:currOpType,subOpType:'edit',formData:scope.row,title:'修改'})" icon="edit" title="修改一条数据"/>
             <el-button :disabled="disBtn('delBtn') || !checkBtnQx('delBtn',menuDefId) " type="danger" @click="handleDel(scope.row,scope.$index)" icon="delete"  title="删除一条数据"/>
        </template>

        <template #default="scope" v-else-if="currOpType=='list'" >
            <el-button   type="primary" @click="openForm({parentOpType:currOpType,subOpType:'detail',formData:scope.row})" icon="view"/>
        </template>

        <template #default="scope" v-else-if="currOpType=='select' && this.multiple!=true" >
            <el-button   type="primary" @click="selectConfirm(scope.row)" icon="check"/>
        </template>
    </el-table-column>
</el-table>
<el-pagination
    layout="slot,total, sizes, prev, next,pager,jumper"
    @current-change="handleCurrentChange"
    @size-change="handleSizeChange"
    :page-sizes="[10,20, 50, 100, 500]"
    :current-page="pageInfo.pageNum"
    :page-size="pageInfo.pageSize"
    :total="pageInfo.total"
    style="float:right;"
/>
<!--新增修改明细 UserJoinRequire 企业入驻审核流程界面-->
<mdp-dialog ref="UserJoinRequireFormDialog">
    <template v-slot="{visible,data}">
         <UserJoinRequireForm ref="UserJoinRequireForm" :someOpen="true" :visible="visible" :parentOpType="currOpType" :subOpType="data.subOpType" :formData="data.formData" @close="onFormClose" @submit="afterFormSubmit" @fields-change="afterEditSomeFields"/>
    </template>
</mdp-dialog>
</template>

<script>

import { MdpTableMixin } from '@/components/mdp-ui/mixin/MdpTableMixin.js';
import * as UserJoinRequireApi from '@/api/mdp/sys/userJoinRequire';
import  UserJoinRequireForm from'./Form.vue';//新增修改明细界面
import { mapState } from 'pinia'
import { useUserStore } from '@/store/modules/user'

export default {
    name:'UserJoinRequireMng',
    mixins:[MdpTableMixin],
    props:{
        someOpen:{
            type: Boolean,
            default: false
        }
    },
    components: {
        UserJoinRequireForm
    },
    computed: {
        ...mapState(useUserStore,['userInfo'])
    },
    watch:{
    },
    data() {
        return {
            menuDefId:'',//menu_def.id 菜单表菜单编号，用于按钮权限判断
            menuDefName:'企业入驻审核流程',//menu_def.name 功能名称，用于导出excel等文件名
            refId:'UserJoinRequire',//引用编号，<table :ref="refId+'Table'"> <form :ref="refId+'Form'">
            pkNames:["id"],//表格主键的java属性名称，驼峰命名，默认为id,支持多主键
            currOpType:'mng',//表格 mng-综合管理具有最大权限，所有按钮可动、detail-只看不能操作
            filters:{//查询参数

            },
            defaultFilters:{//默认查询参数,第一次打开界面的时候用到，恢复默认值的时候用到

            },

            //增删改查(含批量)接口
            apis:{
                list: UserJoinRequireApi.listUserJoinRequire,
                add: UserJoinRequireApi.addUserJoinRequire,
                del: UserJoinRequireApi.delUserJoinRequire,
                edit: UserJoinRequireApi.editUserJoinRequire,
                editSomeFields: UserJoinRequireApi.editSomeFieldsUserJoinRequire,
                batchAdd: UserJoinRequireApi.batchAddUserJoinRequire,
                batchDel: UserJoinRequireApi.batchDelUserJoinRequire,
                batchEdit: UserJoinRequireApi.batchEditUserJoinRequire,
            }
        }
    },
    methods: {
         //页面初始化需要配置的特殊逻辑写这里
          initCurrData(){
             this.searchTableDatas();
          },

          /**
           * 检查参数是否满足调用后台接口的条件
           *
           * @param params 提交给后台的参数池,map类型
           * @returns true / false
           */
          preQueryParamCheck(params){
              return true;
          },

          //页面数据加载完后需要对数据进行加工处理的
          afterList(tableDatas,isOk,apiName){

          },

          /**
           * 对修改的字段进行判断，返回false ,将取消更新数据库
           * @param {*} row 当前选中的行
           * @param {*} fieldName 修改的字段名
           * @param {*} $event 修改后的值
           * @param {*} params 将要提交服务器的参数
           * @returns true/false 返回false ,将取消更新数据库
           */
          editSomeFieldsCheck(row,fieldName,$event,params){
              if(this.currOpType=='add'||this.currOpType=='detail'){
                  return false;
              }
              params[fieldName]=$event
              return true;
          },
    },
    mounted() {

    }
}

</script>

<style scoped>
</style>